added Feb 2001 SDK
[windows-sources.git] / shared source / sscli20 / jscript / engine / vbarrayobject.cs
blob1180d0d5988ea98efb716ac220e9e8ce69f35de9
1 // ==++==
2 //
3 //
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
5 //
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
10 //
11 // You must not remove this notice, or any other, from this software.
12 //
13 //
14 // ==--==
16 namespace Microsoft.JScript {
18 using Microsoft.JScript.Vsa;
19 using System;
20 using System.Collections;
22 public class VBArrayObject : JSObject{
23 private Array array;
25 public VBArrayObject(VBArrayPrototype parent, Array array)
26 : base(parent){
27 this.array = array;
28 this.noExpando = false;
31 internal virtual int dimensions(){
32 return this.array.Rank;
35 internal virtual Object getItem(Object[] args){
36 if (args == null || args.Length == 0)
37 throw new JScriptException(JSError.TooFewParameters);
38 if (args.Length == 1)
39 return this.array.GetValue(Convert.ToInt32(args[0]));
40 if (args.Length == 2)
41 return this.array.GetValue(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]));
42 if (args.Length == 3)
43 return this.array.GetValue(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
44 int n = args.Length;
45 int[] intArgs = new int[n];
46 for (int i = 0; i < n; i++)
47 intArgs[i] = Convert.ToInt32(args[i]);
48 return this.array.GetValue(intArgs);
51 internal virtual int lbound(Object dimension){
52 int dim = Convert.ToInt32(dimension);
53 return this.array.GetLowerBound(dim);
56 internal virtual ArrayObject toArray(VsaEngine engine){
57 IList aList = this.array;
58 ArrayObject result = engine.GetOriginalArrayConstructor().Construct();
59 uint i = 0;
60 int n = aList.Count;
61 IEnumerator e = aList.GetEnumerator();
62 result.length = n;
63 while (e.MoveNext())
64 result.SetValueAtIndex(i++, e.Current);
65 return result;
68 internal virtual int ubound(Object dimension){
69 int dim = Convert.ToInt32(dimension);
70 return this.array.GetUpperBound(dim);